package com.kkb.service.impl;

import com.kkb.mapper.TUserMapper;
import com.kkb.pojo.TUser;
import com.kkb.pojo.TUserExample;
import com.kkb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private TUserMapper tUserMapper;
    @Override
    public TUser findByUserName(String userName) {

        TUserExample tUserExample = new TUserExample();
        TUserExample.Criteria criteria = tUserExample.createCriteria();
        criteria.andUsernameEqualTo(userName);//按名字查询

        List<TUser> userList = tUserMapper.selectByExample(tUserExample);//按名字查询用户
        if(!userList.isEmpty()) {
            return userList.get(0);
        }

        return null;
    }
}
